<template>
  <div>
    <div class="Bsucess">
      <h1>支付成功!</h1>
      <img src="../assets/img/2AC2D536CA004F7734A23AF788531EF9.jpg" class="SPicture" width="100%" height="100%"
           style="z-index:-100;position:fixed;left:0;top:0">
    </div>
    <div>
      <!--查看订单按钮-->
      <input class="Sbtnone" type="button" value="查看订单" id="btn_look" @click="toOrderDetail">
      <!--查看订单按钮-->
      <input class="Sbtntwo" type="button" value="返回首页" id="btn_returnPage" @click="toHomePage">
    </div>
  </div>
</template>

<script>
  import {findNewstOrder} from '@/api/user'

  export default {
    name: 'BuySuccess',
    data () {
      return {
        orderNumber: '',
      }
    },
    methods: {
      toHomePage () {
        this.$router.replace('/HomePage')
      },
      toOrderDetail () {
        this.$router.replace({
          path: '/OrderDetail',
          query: {
            mid: this.$route.query.mid,
            orderNumber: this.orderNumber,
          }
        })
      },
      //查询最新生成的订单号
      findNewstOrderByUid () {
        findNewstOrder({
          uid: this.$store.state.user.uid,
        }).then(res => {
          this.orderNumber = res.data.data
        })
      }
    },
    created () {
      this.findNewstOrderByUid()
    }
  }
</script>
<style scoped>
  .Bsucess {
    font-size: 20px;
    font-family: "SimHei";
    margin-top: 60%;
  }

  .SPicture {
    opacity: 0.7;
  }

  .Sbtnone {
    background-color: white;
    color: black;
    width: 100px;
    height: 40px;
    border: 0;
    border-radius: 30px;
    opacity: 0.7;
  }

  .Sbtntwo {
    background-color: white;
    color: black;
    width: 100px;
    height: 40px;
    border: 0;
    border-radius: 30px;
    opacity: 0.7;
  }
</style>
